package com.example.stomp.controller;

import com.example.stomp.domain.ServerMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:
 * @author: wangshunxin
 * @Date: 2021/3/18
 */
@RestController
@RequestMapping("/hello")
public class TestController {
    @Autowired
    SimpMessagingTemplate messagingTemplate;

    @GetMapping("/a")
    public void helloWorld(){
        messagingTemplate.convertAndSend("/topic/subscribeTest", new ServerMessage("服务器主动推的数据"));
    }
}
